<include file="App/Home/View/Public/header.html"/>
	<div class="col-sm-9 col-sm-offset-3 col-lg-10 col-lg-offset-2 main">			
		<div class="row">
			<ol class="breadcrumb">
				<li class="active position_tit">银行卡管理<span style=" padding:0px 5px;">/</span>添加银行卡</li>
			</ol>
		</div><!--/.row-->
		
		<div class="row">
			<div class="col-lg-12">
				<div class="panel panel-default">
					<div class="panel-heading">添加银行卡信息<span></span></div>
					<div class="panel-body">
                    <form>
					  <table class="table2 card_input" style=" border-collapse: inherit;">
                            <tbody>
                              <tr>
                                <td class="right1 td1" style=" padding-right:0px;">新标签：</td>
                                <td class="left1 td2" style=" padding-left: 0px;"><input style=" width:300px;" name="bname" class="form-control" Placeholder="例：提现卡01" id="bname" value="{$bank_user[bname]}"></td>
                                <td class="left1 td3"><span>备注个人信息</span></td>
                              </tr>
                              <tr>
                                <td class="right1 td1" style=" padding-right:0px;">开户姓名：</td>
                                <td class="left1 td2" style=" padding-left: 0px;"><input style=" width:300px;" name="cardname" id="cardname" class="form-control" disabled="disabled" Placeholder="{$username}" value="{$username}"></td>
                                <td class="left1 td3"><span>与实名认证信息一致不可修改</span></td>
                              </tr>
                              <tr>
                                <td class="right1 td1" style=" padding-right:0px;">银行名称：</td>
                                <td class="left1 td2" style=" padding-left: 0px;">
                                  <select style="width:300px; border-radius:4px; border:1px solid #eee; padding:6px 8px;" name="bankname" id="bankname">
                                    <option value="">请选择银行</option>
									<foreach name="res" item="res">
										<option  value="{$res[name]}" <eq name="res.name" value="$bank_user.bankname">selected="selected"</eq>>{$res.name}</option>
									</foreach>
                                  </select>
                                </td>
                              </tr>
                              <tr>
                                <td class="right1 td1" style=" padding-right:0px;">银行卡所在地：</td>
                                <td class="left1 td2" style=" padding-left: 0px;"><input style=" width:300px;" class="form-control" name="address" id="address" value="{$bank_user[address]}"></td>
                              </tr>
                              <tr>
                                <td class="right1 td1" style=" padding-right:0px;">银行卡号：</td>
                                <td class="left1 td2" style=" padding-left: 0px;"><input style=" width:300px;" class="form-control" name="cardnum" id="cardnum" value="{$bank_user[cardnum]}"></td>
                                <td class="left1 td3"><span class="red">银行卡号和开户姓名必须一致，否则无法到账</span></td>
                              </tr>
                            </tbody>
						</table>
							<input type="hidden" name="uid" value="{$_SESSION['USER_KEY_ID']}" id="uid">
						<span style="display:none" id="bank_id">{$bank_user['id']}</span>
                    </form>
                        <div class="panel-footer">
						<div class="input-group article_btn">
							<span class="input-group-btn">
								<a><button class="btn btn-success btn-md btn_art_return" onClick="doedit()">确认</button></a>
							</span>
						</div>
					</div>	
					</div>
				</div>
			</div>
		</div><!--/.row-->
	</div>	<!--/.main-->	

<script src="__PUBLIC__/Home/js/jquery-1.7.2.min.js"></script>
<script>
	function doedit(){
		var bname = $('#bname').val();
		var bankname = $('#bankname').val();
		var address = $('#address').val();
		var cardnum = $('#cardnum').val();
		if(cardnum == ""){
			alert("银行卡号不能为空");return;
		}
		if(isNaN(cardnum)){
			alert("银行卡号不能含有除数字之外的字段");return;
		}
		var cardname = $('#cardname').val();
		var id = $('#bank_id').html();
		var url = "{:U('Pay/card_insert')}";
	//	$.post(url,{'bname':bname,'bankname':bankname,'address':address,'cardnum':cardnum,'id':id},function(data){
//			console.log(data);
//			if(data['status']==1){
//				alert(data['info']);
//				window.location.href='{:U("Pay/bank_card")}';
//				//   不能获获取uid的值
//			}else{
//				alert(data['info']);
//			}
//		})	
				$.ajax({
				url:url,
				type:'post',                     //发送方式
	            data:{'bname':bname,'bankname':bankname,'address':address,'cardnum':cardnum,'id':id},          //请求数据
	            async:true,                     //是否同步
	            dataType:'json',                //响应的数据类型
	            success:function(data){         //成功回调函数
					 if(data['status']==1){
						alert(data['info']);
						window.location.href='{:U("Pay/bank_card")}';
					}else{
						alert(data['info']);
					}
	            },
				error:function(){
					alert("请求超时");
				}
			})
	}
</script>
</html>

